<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var r = Math.round(Math.random()*10);
    while (true){
        var inputV = prompt('请输入一个数');
        if (inputV == r){
            alert('正确')
            break;
        }
    }
</script>
</body>
</html>